<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="resposta" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{respostaHome.managed ? 'Edit' : 'Add'} Resposta</f:facet>




            <s:decorate id="dataField" template="layout/edit.xhtml">
                <ui:define name="label">Data</ui:define>
                <h:inputText id="data"
                          value="#{respostaHome.instance.data}">
                    <a:support event="onblur" reRender="dataField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>



            <s:decorate id="textoField" template="layout/edit.xhtml">
                <ui:define name="label">Texto</ui:define>
                <h:inputTextarea id="texto"
                               cols="80"
                               rows="3"
                              value="#{respostaHome.instance.texto}"/>
            </s:decorate>

            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{respostaHome.persist}"
                       disabled="#{!respostaHome.wired}"
                       rendered="#{!respostaHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{respostaHome.update}"
                       rendered="#{respostaHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{respostaHome.remove}"
                      immediate="true"
                       rendered="#{respostaHome.managed}"/>

            <s:button id="done"
                   value="Done"
             propagation="end"
                    view="/Resposta.xhtml"
                rendered="#{respostaHome.managed}"/>

            <s:button id="cancel"
                   value="Cancel"
             propagation="end"
                    view="/#{empty respostaFrom ? 'RespostaList' : respostaFrom}.xhtml"
                rendered="#{!respostaHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Criador">
    <div class="association" id="criadorParent">

        <h:outputText value="There is no criador associated with this resposta."
                   rendered="#{respostaHome.instance.criador == null}"/>

        <rich:dataTable var="_usuario"
                   value="#{respostaHome.instance.criador}"
                rendered="#{respostaHome.instance.criador != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="criadorTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_usuario.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Login</f:facet>
                <h:outputText value="#{_usuario.login}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Tipo</f:facet>
                <h:outputText value="#{_usuario.tipo}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button value="#{respostaHome.instance.criador != null ? 'Change' : 'Select'} criador"
                       view="/UsuarioList.xhtml">
                <f:param name="from" value="RespostaEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Incidente">
    <div class="association" id="incidenteParent">

        <h:outputText value="There is no incidente associated with this resposta."
                   rendered="#{respostaHome.instance.incidente == null}"/>

        <rich:dataTable var="_incidente"
                   value="#{respostaHome.instance.incidente}"
                rendered="#{respostaHome.instance.incidente != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="incidenteTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_incidente.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Criador id</f:facet>
                <h:outputText value="#{_incidente.criador.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Data</f:facet>
                <h:outputText value="#{_incidente.data}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Descricao</f:facet>
                <h:outputText value="#{_incidente.descricao}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Prioridade</f:facet>
                <h:outputText value="#{_incidente.prioridade}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Status</f:facet>
                <h:outputText value="#{_incidente.status}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button value="#{respostaHome.instance.incidente != null ? 'Change' : 'Select'} incidente"
                       view="/IncidenteList.xhtml">
                <f:param name="from" value="RespostaEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
